﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web;

namespace tour.szhome.common
{
    /// <summary>
    /// 静态文件引用
    /// </summary>
    public static class CommPath
    {
        /// <summary>
        /// 引用样式文件
        /// </summary>
        /// <param name="paths"></param>
        /// <returns></returns>
        public static IHtmlString StyleImport(string paths)
        {
            return new HtmlString("<link href=\"" + StyleBaseUrl.TrimEnd('/') + "/" + paths.ToString() + "\" rel=\"stylesheet\" />");
        }

        /// <summary>
        /// 引用 脚本文件
        /// </summary>
        /// <param name="paths"></param>
        /// <returns></returns>
        public static IHtmlString ScriptImport(string paths)
        {
            return new HtmlString("<script type=\"text/javascript\" src=\"" + ScriptBaseUrl.TrimEnd('/') + "/" + paths.ToString() + "\" ></script>");
        }

        /// <summary>
        /// 引用 静态文件
        /// </summary>
        /// <param name="paths"></param>
        /// <returns></returns>
        public static IHtmlString FileImport(string paths)
        {
            return new HtmlString(FileBaseUrl.TrimEnd('/') + "/" + paths.ToString());
        }

        /// <summary>
        /// 样式文件地址
        /// </summary>
        public static string StyleBaseUrl
        {
            get
            {
                var basePath = System.Configuration.ConfigurationManager.AppSettings["web_style_path"];
                if (string.IsNullOrEmpty(basePath))
                {
                    return "/style/";
                }
                else
                {
                    return basePath.ToString();
                }

            }
        }

        /// <summary>
        /// 脚本文件地址
        /// </summary>
        public static string ScriptBaseUrl
        {
            get
            {
                var basePath = System.Configuration.ConfigurationManager.AppSettings["web_script_path"];
                if (string.IsNullOrEmpty(basePath))
                {
                    return "/style/";
                }
                else
                {
                    return basePath.ToString();
                }

            }
        }

        /// <summary>
        /// 静态文件地址
        /// </summary>
        public static string FileBaseUrl
        {
            get
            {
                var basePath = System.Configuration.ConfigurationManager.AppSettings["web_file_path"];
                if (string.IsNullOrEmpty(basePath))
                {
                    return "/style/";
                }
                else
                {
                    return basePath.ToString();
                }

            }
        }
    }
}
